//
//  ViewControllerB.m
//  NAVI
//
//  Created by student on 16/2/25.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewControllerB.h"
#import "ViewControllerA.h"
#import "ViewControllerC.h"
#import "ViewControllerD.h"

@interface ViewControllerB ()

@end

@implementation ViewControllerB
- (IBAction)toA:(id)sender
{
    ViewControllerA *vca= [[ViewControllerA alloc]init];
    [self.navigationController pushViewController:vca animated:YES];
}
- (IBAction)toB:(id)sender
{
    ViewControllerB *vcb= [[ViewControllerB alloc]init];
    [self.navigationController pushViewController:vcb animated:YES];
}
- (IBAction)toC:(id)sender
{
    ViewControllerC *vcc= [[ViewControllerC alloc]init];
    [self.navigationController pushViewController:vcc animated:YES];
}
- (IBAction)toD:(id)sender
{
    ViewControllerD *vcd= [[ViewControllerD alloc]init];
    [self.navigationController pushViewController:vcd animated:YES];
}
- (IBAction)pop:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)poptotwo:(id)sender
{
    if(self.navigationController.viewControllers.count>2)
    {
        [self.navigationController popToViewController:self.navigationController.viewControllers[1] animated:YES];
    }
}
- (IBAction)porrppt:(id)sender
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIBarButtonItem *leftitem=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:nil action:nil];
    self.navigationItem.leftBarButtonItem=leftitem;
    UISegmentedControl *seg=[[UISegmentedControl alloc]initWithItems:@[@"A",@"B"]];
    seg.frame=CGRectMake(0, 0, 100, 30);
    self.navigationItem.titleView=seg;
    UIBarButtonItem *rightitem=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:nil action:nil];
    self.navigationItem.rightBarButtonItem=rightitem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
